﻿using System;


using System.Text;
using IAM.Interface.Model;
using IAM.Interface.Model.ENUM;
using IAM.Interface.IDAL;
using System.Web;
using IAM.Interface.Common.Context;
using IAM.Interface.DAL.Request.Interface;

namespace IAM.Interface.DAL.Request
{
    /// <summary>
    /// 人员信息管理
    /// </summary>
    public class IdentityMgnt : AbstractAppType,IIdentityMgnt
    {

        #region  成员方法
        /// <summary>
        /// 创建用户
        /// 1.实例化RequestContextModel对象
        /// 2.实例化请求端上下文控制对象
        /// 3.发送消息
        /// 4.接收消息
        /// 5.转换通用类的类型
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo CreateIdentity(Identity identity)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.IDEN_MANAGE, 
                OperationType.Create, 
                identity,
                identity.GetType(), 
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn=rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            return (AccountInfo)obj;
        }
        /// <summary>
        /// 激活用户
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo EnableIdentity(Identity identity)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.IDEN_MANAGE,
                OperationType.Enable,
                identity,
                identity.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            return (AccountInfo)obj;
        }
        /// <summary>
        /// 禁用用户
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo DisableIdentity(Identity identity)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.IDEN_MANAGE,
                OperationType.Disable,
                identity,
                identity.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            return (AccountInfo)obj;
        }
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo DeleteIdentity(Identity identity)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.IDEN_MANAGE,
                OperationType.Delete,
                identity,
                identity.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            return (AccountInfo)obj;

        }
        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <param name="identity">人员身份信息</param>
        /// <returns>人员账号信息</returns>
        public virtual AccountInfo UpdateIdentity(Identity identity)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.IDEN_MANAGE,
                OperationType.Update,
                identity,
                identity.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            return (AccountInfo)obj;
        }
        #endregion  成员方法
    }
}
